class Calc<T extends Number> {
    private T[] a;
    public Calc(T[] a){
        this.a =a;
    }
    public double sum(){
        double sum=0;
        for (T n:a){
            sum+=n.doubleValue();
        }
        return sum;
    }
    public double average(){
        return sum()/a.length;
    }
}
public class eg8_3 {
    public static void main(String[] args) {
        Integer iNums[]={1,2,3,4,5,6};
        Calc<Integer>c1=new Calc<Integer>(iNums);
        System.out.println("整数组iNUma的和值为："+c1.sum()+",平均值为："+c1.average());
        Double dNums[]={1.1,2.2,3.3,4.4,5.5};
        Calc<Double>c2=new Calc<Double>(dNums);
        System.out.println("整数组dNUma的和值为："+c2.sum()+",平均值为："+c2.average());
    }
}
